﻿using HelloLLLLL.Blog.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HelloLLLLL.Blog.DAL;

namespace HelloLLLLL.Blog.Admin.page
{
    
    public partial class UserSetting : System.Web.UI.Page
    {
        public UserInfo LLuser = null;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            LLuser = (UserInfo)Context.Session["userInfo"];

            if (IsPostBack)
            {
                UserInfoAE();
            }

        }
        private void UserInfoAE()
        {
            UserInfo u = new UserInfo();

            string id = Request["id"];
            u.Address = Request["address"];
            u.Introduce = Request["introduce"];
            u.Nick = Request["username"];
            u.Password = LLuser.Password;
            u.photo = LLuser.photo;
            if (string.IsNullOrWhiteSpace(id))
            {
                Response.Redirect("/Admin/AdminLogin.aspx");
            }
            u.Id = int.Parse(id);

            string sql = SqlBuilderHelper.UpdateSql<UserInfo>(u, "UserInfo");

           if( new DBHelper().GetNonQuery(sql) > 0)
            {
                

                Context.Session["userInfo"] = u;
                Response.Redirect("/admin/Admin.aspx");

            }


        }
    }
}